package com.zlr.hiring.talent.dao;

import java.util.ArrayList;
import java.util.List;

import com.zlr.hiring.common.util.DBUtil;
import com.zlr.hiring.talent.entity.TalentEntity;

public class TalentDao {
	/**
	 * 求职者注册
	 */
	public int register(TalentEntity talent) {
		String sql = "INSERT into talent VALUES(NULL,?,MD5(?),?,?,?,?,?,?)";
		List<Object> paramList = new ArrayList<>();
		paramList.add(talent.getCode());
		paramList.add(talent.getPassword());
		paramList.add(talent.getName());
		paramList.add(talent.getPhone());
		paramList.add(talent.getEmail());
		paramList.add(talent.getAge());
		paramList.add(talent.getGender());
		paramList.add(talent.getHobby());
		return DBUtil.executeUpdate(sql, paramList);
	}

	/**
	 * 登录
	 */
	public TalentEntity login(String code, String password) {
		String sql = "SELECT id,name FROM talent WHERE code=? AND password=?";
		return DBUtil.getUniqueResult(TalentEntity.class, sql, code, password);
	}

	/**
	 * 查询
	 */
	public TalentEntity get(int id) {
		String sql = "SELECT * FROM talent WHERE id=?";
		return DBUtil.getUniqueResult(TalentEntity.class, sql, id);
	}
}
